package cn.com.surker.business.entity;

import cn.com.surker.base.BaseEntity;
import cn.com.surker.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.List;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 业务操作记录表
 * </p>
 *
 * @author admin
 * @since 2025-04-14
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class BusinessLog extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 标识
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 操作类型(0:过磅单1:生产发货单2:销售发货单)
     */
    private Integer type;

    /**
     * 操作日志
     */
    private String content;

    private Long bizId;
    private String code;
    public BusinessLog() {}
    public BusinessLog(Long bizId, String code, Integer type, String content) {
        this.type = type;
        this.content = content;
        this.bizId = bizId;
        this.code = code;
    }

    public static String convertJson(String[] keys, Object[] vals) {
        if (keys == null || vals == null || keys.length == 0
                || vals.length == 0 || keys.length != vals.length)
            return "";
        JSONObject jsonObject = new JSONObject();
        for (int i = 0 ; i < keys.length; i++) {
            jsonObject.put(keys[i], vals[i]);
        }
        return jsonObject.toJSONString();
    }
    public static String convertJsonV1(List<String> keys, List<Object> vals) {
        if (keys == null || vals == null || keys.size() == 0
                || vals.size() == 0 || keys.size() != vals.size())
            return "";
        JSONObject jsonObject = new JSONObject();
        for (int i = 0 ; i < keys.size(); i++) {
            jsonObject.put(keys.get(i), vals.get(i));
        }
        return jsonObject.toJSONString();
    }
}
